package com.ajnp.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@Slf4j
@RequestMapping("/consumer")
public class NanosController {

    @Autowired
    private RestTemplate restTemplate;

    //在yml文件中定义了 可以读取到yml文件中的数据
    @Value("${service-url.nacos-user-service}")
    private String nacosURL;

    @GetMapping("/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") int id) {
        System.out.println(nacosURL);
        return restTemplate.getForObject(nacosURL + "/payment/getnacos/" + id, String.class);
    }

}
